

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>RESTful 模块 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="Zabbix 模块" href="../zabbix/" />
    <link rel="prev" title="本地存储池模块" href="../localpool/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
          <li><a href="../">Ceph 管理器守护进程</a> &raquo;</li>
      <li>RESTful 模块</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/mgr/restful.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 管理器守护进程</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../administrator/">安装和配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../modules/">模块编程</a></li>
<li class="toctree-l2"><a class="reference internal" href="../orchestrator_modules/">编写 orchestrator 插件</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dashboard/">仪表盘模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph_api/">Ceph RESTful API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../alerts/">Alerts 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../diskprediction/">DiskPrediction 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../localpool/">localpool 模块</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">RESTful 模块</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id1">启用此功能</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">安全加固</a></li>
<li class="toctree-l3"><a class="reference internal" href="#ip">IP 和端口的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="#api">创建一个 API 用户</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">负载均衡器</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">可用方法</a></li>
<li class="toctree-l3"><a class="reference internal" href="#request"><code class="docutils literal notranslate"><span class="pre">/request</span></code> 终结点</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../zabbix/">Zabbix 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../prometheus/">Prometheus 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../influx/">Influx 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hello/">Hello 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../telegraf/">Telegraf 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../telemetry/">Telemetry 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../iostat/">Iostat 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crash/">Crash 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../insights/">Insights 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../orchestrator/">Orchestrator 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rook/">Rook 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rgw/">RGW 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mds_autoscaler/">MDS Autoscaler 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../nfs/">NFS 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../progress/">Progress 模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli_api/">CLI API 命令模块</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">Hardware monitoring</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="restful">
<h1>RESTful 模块<a class="headerlink" href="#restful" title="Permalink to this heading"></a></h1>
<p>REST 风格的模块提供了通过 SSL 加密连接访问集群状态的 REST 风格接口。</p>
<section id="id1">
<h2>启用此功能<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p><em>restful</em> 模块用此命令启用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mgr</span> <span class="n">module</span> <span class="n">enable</span> <span class="n">restful</span>
</pre></div>
</div>
<p>在 API　终结点上线前你还得按下面的文档配置一个 SSL 证书。默认情况下，
此模块会在 <code class="docutils literal notranslate"><span class="pre">8003</span></code> 端口上接受此主机上所有 IPv4 和 IPv6 地址的 HTTPS 请求。</p>
</section>
<section id="id2">
<h2>安全加固<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>到 <em>restful</em> 的所有连接都是用 SSL 加密过的。用下列命令可以生成一个自签名的证书：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">restful</span> <span class="n">create</span><span class="o">-</span><span class="bp">self</span><span class="o">-</span><span class="n">signed</span><span class="o">-</span><span class="n">cert</span>
</pre></div>
</div>
<p>请注意，用自签名证书时，大多数客户端都需要多加个选项以允许这种连接，
并平息警告消息。例如，如果 <code class="docutils literal notranslate"><span class="pre">ceph-mgr</span></code> 守护进程在同一主机上，</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">k</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">localhost</span><span class="p">:</span><span class="mi">8003</span><span class="o">/</span>
</pre></div>
</div>
<p>要给一套设施做好安全加固，应该使用由证书颁发机构签署过的证书。例如，可以用类似如下的命令生成密钥对：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">openssl</span> <span class="n">req</span> <span class="o">-</span><span class="n">new</span> <span class="o">-</span><span class="n">nodes</span> <span class="o">-</span><span class="n">x509</span> \
  <span class="o">-</span><span class="n">subj</span> <span class="s2">&quot;/O=IT/CN=ceph-mgr-restful&quot;</span> \
  <span class="o">-</span><span class="n">days</span> <span class="mi">3650</span> <span class="o">-</span><span class="n">keyout</span> <span class="n">restful</span><span class="o">.</span><span class="n">key</span> <span class="o">-</span><span class="n">out</span> <span class="n">restful</span><span class="o">.</span><span class="n">crt</span> <span class="o">-</span><span class="n">extensions</span> <span class="n">v3_ca</span>
</pre></div>
</div>
<p>生成的 <code class="docutils literal notranslate"><span class="pre">restful.crt</span></code> 应该再由您所在组织的 CA （证书颁发机构）签署。签完后，你可以这样使用它：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ceph config-key set mgr/restful/$name/crt -i restful.crt
ceph config-key set mgr/restful/$name/key -i restful.key
</pre></div>
</div>
<p>其中 <code class="docutils literal notranslate"><span class="pre">name</span></code> 是 <code class="docutils literal notranslate"><span class="pre">ceph-mgr</span></code> 例程的名字（通常是主机名）。如果所有管理器例程共用同一证书，可以省略 <code class="docutils literal notranslate"><span class="pre">$name</span></code> 部分：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">config</span><span class="o">-</span><span class="n">key</span> <span class="nb">set</span> <span class="n">mgr</span><span class="o">/</span><span class="n">restful</span><span class="o">/</span><span class="n">crt</span> <span class="o">-</span><span class="n">i</span> <span class="n">restful</span><span class="o">.</span><span class="n">crt</span>
<span class="n">ceph</span> <span class="n">config</span><span class="o">-</span><span class="n">key</span> <span class="nb">set</span> <span class="n">mgr</span><span class="o">/</span><span class="n">restful</span><span class="o">/</span><span class="n">key</span> <span class="o">-</span><span class="n">i</span> <span class="n">restful</span><span class="o">.</span><span class="n">key</span>
</pre></div>
</div>
</section>
<section id="ip">
<h2>IP 和端口的配置<a class="headerlink" href="#ip" title="Permalink to this heading"></a></h2>
<p>和其它 REST 风格的 API 终结点一样， <em>restful</em> 也是绑定到一个 IP
和端口的。默认情况下，当前活跃的 <code class="docutils literal notranslate"><span class="pre">ceph-mgr</span></code> 守护进程会绑定到
8003 端口和本主机上所有的可用 IPv4 和 IPv6 地址。</p>
<p>由于各个 <code class="docutils literal notranslate"><span class="pre">ceph-mgr</span></code> 管理着它自己的 <em>restful</em> 例程，所以可能得分别配置它们。 IP 和端口可以通过配置键更改：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ceph config set mgr mgr/restful/$name/server_addr $IP
ceph config set mgr mgr/restful/$name/server_port $PORT
</pre></div>
</div>
<p>其中，i <code class="docutils literal notranslate"><span class="pre">$name</span></code> 是 ceph-mgr 守护进程的 ID （通常是主机名）。</p>
<p>这些配置也可以是集群范围的，而不只是特定于管理器的。例如，</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>ceph config set mgr mgr/restful/server_addr $IP
ceph config set mgr mgr/restful/server_port $PORT
</pre></div>
</div>
<p>如果没配置端口， <em>restful</em> 将绑定到 <code class="docutils literal notranslate"><span class="pre">8003</span></code> 端口；如果没配置地址， <em>restful</em> 将绑定到 <code class="docutils literal notranslate"><span class="pre">::</span></code> ，意思是所有可用的 IPv4 和
IPv6 地址。</p>
</section>
<section id="api">
<span id="creating-an-api-user"></span><h2>创建一个 API 用户<a class="headerlink" href="#api" title="Permalink to this heading"></a></h2>
<p>要新建一个 API 用户，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">restful</span> <span class="n">create</span><span class="o">-</span><span class="n">key</span> <span class="o">&lt;</span><span class="n">username</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>把 <code class="docutils literal notranslate"><span class="pre">&lt;username&gt;</span></code> 替换成想要的用户名。例如，
要新建名为 <code class="docutils literal notranslate"><span class="pre">api</span></code> 的用户:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph restful create-key api
52dffd92-a103-4a10-bfce-5b60f48f764e
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">restful</span> <span class="pre">create-key</span> <span class="pre">api</span></code> 命令生成的 UUID 作为此用户的密钥。</p>
<p>要罗列你的所有 API 密钥，运行下列命令:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">restful</span> <span class="nb">list</span><span class="o">-</span><span class="n">keys</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">restful</span> <span class="pre">list-keys</span></code> 会以 JSON 格式输出:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
      <span class="s2">&quot;api&quot;</span><span class="p">:</span> <span class="s2">&quot;52dffd92-a103-4a10-bfce-5b60f48f764e&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>要用 API 测试你的用户，可以用 <code class="docutils literal notranslate"><span class="pre">curl</span></code> ，例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">curl</span> <span class="o">-</span><span class="n">k</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">api</span><span class="p">:</span><span class="mi">52</span><span class="n">dffd92</span><span class="o">-</span><span class="n">a103</span><span class="o">-</span><span class="mi">4</span><span class="n">a10</span><span class="o">-</span><span class="n">bfce</span><span class="o">-</span><span class="mi">5</span><span class="n">b60f48f764e</span><span class="o">@&lt;</span><span class="n">ceph</span><span class="o">-</span><span class="n">mgr</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">port</span><span class="o">&gt;/</span><span class="n">server</span>
</pre></div>
</div>
<p>在上面的例子中， 我们用 <code class="docutils literal notranslate"><span class="pre">GET</span></code> 从 <code class="docutils literal notranslate"><span class="pre">server</span></code> 终结点获取信息。</p>
</section>
<section id="id3">
<h2>负载均衡器<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>请注意，<em>只有</em>当下管理器活跃着时， <em>restful</em> 才能启动。查询 Ceph 集群状态以确定哪个管理器活跃着（例如
<code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">mgr</span> <span class="pre">dump</span></code> ）。为了让 API 有一致的 URL ，而无须操心当前哪个管理器守护进程活跃着，你可以配置一个负载均衡器前端，用以把流量引导到可用的管理器终结点上。</p>
</section>
<section id="id4">
<h2>可用方法<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>你可以浏览 <code class="docutils literal notranslate"><span class="pre">/doc</span></code> 终结点来获取完整的可用终结点列表，以及各终结点已实现的 HTTP 方法。</p>
<p>例如，如果你想用 <code class="docutils literal notranslate"><span class="pre">/osd/&lt;id&gt;</span></code> 终结点的 PATCH 方法，把 OSD
<code class="docutils literal notranslate"><span class="pre">1</span></code> 的状态设置为 <code class="docutils literal notranslate"><span class="pre">up</span></code> ，可以用下面的 curl 命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">echo</span> <span class="o">-</span><span class="n">En</span> <span class="s1">&#39;{&quot;up&quot;: true}&#39;</span> <span class="o">|</span> <span class="n">curl</span> <span class="o">--</span><span class="n">request</span> <span class="n">PATCH</span> <span class="o">--</span><span class="n">data</span> <span class="o">@-</span> <span class="o">--</span><span class="n">silent</span> <span class="o">--</span><span class="n">insecure</span> <span class="o">--</span><span class="n">user</span> <span class="o">&lt;</span><span class="n">user</span><span class="o">&gt;</span> <span class="s1">&#39;https://&lt;ceph-mgr&gt;:&lt;port&gt;/osd/1&#39;</span>
</pre></div>
</div>
<p>或者用 python 这样做：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python
&gt;&gt; import requests
&gt;&gt; result = requests.patch(
       &#39;https://&lt;ceph-mgr&gt;:&lt;port&gt;/osd/1&#39;,
       json={&quot;up&quot;: True},
       auth=(&quot;&lt;user&gt;&quot;, &quot;&lt;password&gt;&quot;)
   )
&gt;&gt; print result.json()
</pre></div>
</div>
<p><em>result</em> 模块里实现的其它终结点包括：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">/config/cluster</span></code>: <strong>GET</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/config/osd</span></code>: <strong>GET</strong>, <strong>PATCH</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/crush/rule</span></code>: <strong>GET</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/mon</span></code>: <strong>GET</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/osd</span></code>: <strong>GET</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/pool</span></code>: <strong>GET</strong>, <strong>POST</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/pool/&lt;arg&gt;</span></code>: <strong>DELETE</strong>, <strong>GET</strong>, <strong>PATCH</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/request</span></code>: <strong>DELETE</strong>, <strong>GET</strong>, <strong>POST</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/request/&lt;arg&gt;</span></code>: <strong>DELETE</strong>, <strong>GET</strong></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">/server</span></code>: <strong>GET</strong></p></li>
</ul>
</section>
<section id="request">
<h2><code class="docutils literal notranslate"><span class="pre">/request</span></code> 终结点<a class="headerlink" href="#request" title="Permalink to this heading"></a></h2>
<p>你用 <strong>DELETE</strong> 、 <strong>POST</strong> 或 <strong>PATCH</strong> 这些方法做过操作后，可以用 <code class="docutils literal notranslate"><span class="pre">/request</span></code> 终结点来轮询这个请求的状态。这些方法默认情况下是异步执行的，因为它们可能得花费较长的时间才能完成；你可以在请求的 URL 后面加上 <code class="docutils literal notranslate"><span class="pre">?wait=1</span></code> 来改变此行为，这样返回的请求就肯定是已完成的。</p>
<p><code class="docutils literal notranslate"><span class="pre">/request</span></code> 的 <strong>POST</strong> 方法提供了直接执行定义在
<code class="docutils literal notranslate"><span class="pre">src/mon/MonCommands.h</span></code> 内的各个 ceph mon 命令的方法：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">COMMAND</span><span class="p">(</span><span class="s2">&quot;osd ls &quot;</span> \
        <span class="s2">&quot;name=epoch,type=CephInt,range=0,req=false&quot;</span><span class="p">,</span> \
        <span class="s2">&quot;show all OSD ids&quot;</span><span class="p">,</span> <span class="s2">&quot;osd&quot;</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">,</span> <span class="s2">&quot;cli,rest&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>命令<strong>前缀</strong>是 <strong>osd ls</strong> 。可选参数的名字是 <strong>epoch</strong> 、其类型是 <code class="docutils literal notranslate"><span class="pre">CephInt</span></code> ，即 <code class="docutils literal notranslate"><span class="pre">integer</span></code> 。如此一来，你可以用下面的 <strong>POST</strong> 请求来调用命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ python
&gt;&gt; import requests
&gt;&gt; result = requests.post(
       &#39;https://&lt;ceph-mgr&gt;:&lt;port&gt;/request&#39;,
       json={&#39;prefix&#39;: &#39;osd ls&#39;, &#39;epoch&#39;: 0},
       auth=(&quot;&lt;user&gt;&quot;, &quot;&lt;password&gt;&quot;)
   )
&gt;&gt; print result.json()
</pre></div>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../localpool/" class="btn btn-neutral float-left" title="本地存储池模块" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../zabbix/" class="btn btn-neutral float-right" title="Zabbix 模块" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>